﻿using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using Yipusoft.Common.Model;
using Yipusoft.Common.BLL;
using AjaxControlToolkit;
using System.Collections.Specialized;
using System.Collections.Generic;

/// <summary>
///TypeDictionaryServices 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。 
[System.Web.Script.Services.ScriptService]
public class TypeDictionaryServices : System.Web.Services.WebService
{

    public TypeDictionaryServices()
    {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod]
    public CascadingDropDownNameValue[] GetPumperDictionary(
      string knownCategoryValues,
      string category)
    {

        List<CascadingDropDownNameValue> values =
         new List<CascadingDropDownNameValue>();
        foreach (CodeItemInfo dict in CodeItem.GetList("ParentID='XFC000' Order by SeqID"))
        {

            string dictionaryName = dict.ItemName;
            string dictionaryID = dict.ItemID;
            values.Add(new CascadingDropDownNameValue(dictionaryName, dictionaryID));

        }
        return values.ToArray();
    }

    [WebMethod]
    public CascadingDropDownNameValue[] GetDictionaryByParentID(
      string knownCategoryValues,
      string category)
    {
        StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        // int departmentID;
        if (!kv.ContainsKey("PumperType"))
        {
            return null;
        }
        string parentID = kv["PumperType"];

        //string departmentId = "0900001";
        List<CascadingDropDownNameValue> values =
          new List<CascadingDropDownNameValue>();
        foreach (CodeItemInfo dict in CodeItem.GetList("ParentID='"+parentID+"' order by seqID"))
        {
            values.Add(new CascadingDropDownNameValue(dict.ItemName, dict.ItemID));
        }

        return values.ToArray();
    }

}

